<link type="text/css" rel="stylesheet" href="<?php echo $this->basePath('public/css/dbblack/css/ucenter.css'); ?>" />
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/artDialog.js?skin=simple'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/plugins/iframeTools.js'); ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $this->basePath('public/css/dbblack/js/form/style.css'); ?>"/>

<div class="container clearfix">
    <?php echo $this->partial('shopfront/home/left_menu.phtml'); ?>
    <div class="content clearfix uc-content">
        <h1 class="title"><span><?php echo $this->translate('我的优惠券'); ?>：</span></h1>
        <div class="order-menu">
            <ul class="tab-head">
                <li <?php if ($this->state == 'all') echo 'class="current"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'all'))); ?>"><?php echo $this->translate('全部优惠券'); ?><?php if ($this->coupon_num['all']>0) { ?>(<font color="red"><?php echo $this->coupon_num['all']; ?></font>)<?php } ?></a></li>
                <li <?php if ($this->state == '0') echo 'class="current"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'0'))); ?>"><?php echo $this->translate('未生效优惠券'); ?><?php if ($this->coupon_num['0']>0) { ?>(<font color="red"><?php echo $this->coupon_num['0']; ?></font>)<?php } ?></a></li>
                <li <?php if ($this->state == '1') echo 'class="current"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'1'))); ?>"><?php echo $this->translate('可用优惠券'); ?><?php if ($this->coupon_num['1']>0) { ?>(<font color="red"><?php echo $this->coupon_num['1']; ?></font>)<?php } ?></a></li>
                <li <?php if ($this->state == '2') echo 'class="current"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'2'))); ?>"><?php echo $this->translate('已用优惠券'); ?><?php if ($this->coupon_num['2']>0) { ?>(<font color="red"><?php echo $this->coupon_num['2']; ?></font>)<?php } ?></a></li>
                <li <?php if ($this->state == '3') echo 'class="current"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'3'))); ?>"><?php echo $this->translate('过期优惠券'); ?><?php if ($this->coupon_num['3']>0) { ?>(<font color="red"><?php echo $this->coupon_num['3']; ?></font>)<?php } ?></a></li>
            </ul>
        </div>
        <?php if ($this->user_coupon_list) { ?>
            <table class="simple attention">
                <tr>
                    <th width="15%"><?php echo $this->translate('优惠券名称'); ?></th>
                    <th width="25%"><?php echo $this->translate('优惠券描述'); ?></th>
                    <th width="10%"><?php echo $this->translate('优惠券状态'); ?></th>
                    <th width="20%"><?php echo $this->translate('有效期'); ?></th>
                    <th width="20%"><?php echo $this->translate('使用优惠券的订单号'); ?></th>
                </tr>
                <?php foreach ($this->user_coupon_list as $coupon_key => $coupon_value) { ?>
                    <tr class="<?php echo $coupon_key%2==1 ? 'even' : 'odd'; ?>">
                        <td><?php echo $this->escapeHtml($coupon_value['coupon_name']); ?></td>
                        <td><?php echo $this->escapeHtml($coupon_value['coupon_info']); ?></td>
                        <td>
                            <?php
                            $couponStateArray = array(0=>$this->translate('未生效优惠券'), 1=>$this->translate('可用优惠券'), 2=>$this->translate('已用优惠券'), 3=>$this->translate('过期优惠券'));
                            echo $couponStateArray[$coupon_value['coupon_use_state']];
                            ?>
                        </td>
                        <td>
                            <?php
                            $start_time = empty($coupon_value['coupon_start_use_time']) ? '' : date("Y-m-d H:i", $coupon_value['coupon_start_use_time']);
                            $end_time   = empty($coupon_value['coupon_expire_time']) ? '' : date("Y-m-d H:i", $coupon_value['coupon_expire_time']);
                            if($start_time == '' and $end_time == '') {
                                $start_and_end_time = $this->translate('长期有效');
                            } elseif ($end_time != '' and time() > $coupon_value['coupon_expire_time']) {
                                $start_and_end_time = '<font color="#FF0000">' . $this->translate('已经过期') . '</font>';
                            } else {
                                $start_and_end_time = (empty($start_time) ? $this->translate('无') : $start_time) . ' / ' . (empty($end_time) ? $this->translate('无') : $end_time);
                            }

                            echo $start_and_end_time; ?>
                        </td>
                        <td><?php echo $coupon_value['used_order_sn']; ?></td>
                    </tr>
                <?php } ?>
            </table>
            <div class="page-nav">
                <?php echo ( count($this->user_coupon_list) > 0 ) ? $this->paginationControl($this->user_coupon_list, 'Sliding', 'site/dbpage',array('page_url'=>$this->url('frontcoupon/default/coupon_page', array('action'=>'index', 'id'=>0), array('query'=>array('state'=>$this->state))))) : ""; ?>
            </div>
        <?php } else { ?>
            <p><?php echo $this->translate('暂无优惠券！'); ?></p>
        <?php } ?>
    </div>
</div>